let baseurl = "https://api-hmugo-web.itheima.net/api";
const request = (params) => {
    wx.showLoading({
        title: '加载中',
    })
    //只要发送请求就有一个loading
    return new Promise((resolve, reject) => {
        wx.request({
            ...params,
            url: baseurl + params.url,
            success(res) {
                // console.log(res);
                resolve(res.data)
            },
            fail(err) {
                reject(err)
            },
            complete() {
                wx.hideLoading()
            }
            //只要完成请求就关闭loading
        })
    })
}

export default request